/* 
 *   Date       Developer   Description
 *   
 *
 *   Classname:  zzz.developers.SpringRoute.services.RefProcessor
 * 
 *   Date:   2014-3-12
 * 
 *   The source code contained in this listing is proprietary to
 *   HLJ POST YITONG INFO-NET CO.,LTD.
 * 
 *   Unauthorized copying, adaptation, distribution, use, or display
 *   is strictly prohibited.
 *   This software is Copyright 2014 HLJ POST YITONG INFO-NET CO.,LTD.
 */
package com.titan.demo.camel.developers.SpringRoute.services;

import org.apache.camel.Exchange;
import org.apache.camel.Message;
import org.apache.camel.Processor;


/**
 *
 *
 * @author Administrator
 *
 */
public class RefProcessor implements Processor {
    private String beanid;
    private String method;
    private Boolean async;
    
    
    public void process(Exchange exchange) throws Exception {
        final Message in = exchange.getIn();
        if(async) {
            Utils.run(new Runnable() {
                public void run() {
                    try {
                        Utils.invoke(beanid, method, new Object[]{in.getBody()});
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        } else {
            Utils.invoke(beanid, method);
        }
    }


    
    public String getBeanid() {
        return beanid;
    }

    public void setBeanid(String beanid) {
        this.beanid = beanid;
    }
    
    public String getMethod() {
        return method;
    }
    
    public void setMethod(String method) {
        this.method = method;
    }
    
    public Boolean getAsync() {
        return async;
    }
    
    public void setAsync(Boolean async) {
        this.async = async;
    }
}

